package com.cebbank.service;

import com.cebbank.bo.UserBO;
import com.cebbank.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author name:dss
 * @version 1.0
 * @description: TODO
 * @date 2022/8/252022/8/25
 */
@Component
public class UserServiceImpl implements UserService {

    private final UserMapper userMapper;
    @Autowired
    public UserServiceImpl(UserMapper userMapper){
        this.userMapper=userMapper;
    }

    @Override
    public void showUserList() {
        List<UserBO> u=userMapper.getUserList();
        u.forEach(System.out::println);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void transferAccount() {
        userMapper.updateAmountByName("小明",400);
        int i=1/0;
        userMapper.updateAmountByName("小红",600);
    }
}
